<?php

namespace app\api\controller;

use app\common\lib\Param;
use app\common\lib\Show;
use app\common\lib\Str;
use app\Request;
use think\facade\Cache;

class Department extends ApiBase
{
    public function index(){
        $departmentBis = new \app\common\business\Department();
        $list = $departmentBis->getListByWhere([],0,0,'id,name');
        return Show::success($list);
    }

    //获取人力资源公司详情
    public function detail()
    {
        $id = input("id", 0, "intval");

        $departmentBis = new \app\common\business\Department();
        $info = $departmentBis->getNormalById($id);
        return Show::success($info, "OK");
    }

    //获取指定人力资源公司评价列表
    public function getListByDepartmentId(){
        $associated_id = input("associated_id", 0, "intval");
        $type = input("type", 0, "intval");
        $page = input("page", 0, "intval");
        $limit = input("limit", 0, "intval");

        //筛选条件
        $where = [
            ['associated_id','=',$associated_id],
            ['type','=',$type],//2或3
        ];
        $commentsBis = new \app\common\business\Comments();
        $list = $commentsBis->getListByWhere($where,$page,$limit);
        $total=$commentsBis->getCountByWhere($where,'id');

        if (!empty($list)) {
            //关联展示评价者用户信息
            $list = $commentsBis->resetTextList($list);//reset
        }
        return Show::success(['list'=>$list,'count'=>$total], "OK");
    }
}